import asyncio
from typing import List

from llama_index.core.agent.workflow import  FunctionAgent
from llama_index.core.base.llms.types import ChatMessage
from llama_index.core.storage.chat_store.sql import SQLAlchemyChatStore
from llama_index.core.tools import QueryEngineTool
from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.schema import  TextNode
from llama_index.core import Settings, SimpleKeywordTableIndex, SummaryIndex, get_response_synthesizer, StorageContext, \
    VectorStoreIndex
from llama_index.embeddings.zhipuai import ZhipuAIEmbedding
from llama_index.core.graph_stores import SimplePropertyGraphStore
from llama_index.core.schema import Document
from pydantic import BaseModel, Field

embed_model = ZhipuAIEmbedding(
    model="embedding-2",
    api_key="f387f5e4837d4e4bba6d267682a957c9.PmPiTw8qVlsI2Oi5"
    # With the `embedding-3` class
    # of models, you can specify the size
    # of the embeddings you want returned.
    # dimensions=1024
)
Settings.embed_model=embed_model

from llama_index.llms.deepseek import DeepSeek

llm = DeepSeek(model="deepseek-chat", api_key="sk-605e60a1301040759a821b6b677556fb")
Settings.llm = llm


from llama_index.core.types import BaseOutputParser
from llama_index.core.output_parsers.langchain import LangchainOutputParser
from llama_index.core.output_parsers.pydantic import PydanticOutputParser
from llama_index.core.output_parsers.selection import SelectionOutputParser




class Person(BaseModel):
    """Data model for an Amazon Product."""
    title: str = Field(..., description="Title of product")
    price: float = Field(..., description="Price of product")


outputParser=SelectionOutputParser(output_cls=Person)
format_instructions = outputParser.get_format_string()
print(format_instructions)
print("sss")


prompt = f"""
请根据以下描述生成规范的信息：
要求：{format_instructions}
"""

llm_output = llm.complete(prompt)  # 调用LLM获取原始输出
print(llm_output)
parsed_result = outputParser.parse(llm_output.text)

'''

class Person(BaseModel):
    """Data model for an Amazon Product."""
    title: str = Field(..., description="Title of product")
    price: float = Field(..., description="Price of product")


outputParser=PydanticOutputParser(output_cls=Person)
format_instructions = outputParser.get_format_string()
print(format_instructions)
print("sss")


prompt = f"""
请根据以下描述生成规范的信息：
要求：{format_instructions}
"""

llm_output = llm.complete(prompt)  # 调用LLM获取原始输出
print(llm_output)
parsed_result = outputParser.parse(llm_output.text)
'''